home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / NET / NetworkClient.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  1.2 KB  |  49 lines

  1. package sun.net;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.BufferedOutputStream;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.io.PrintStream;
  8. import java.net.Socket;
  9. import java.net.UnknownHostException;
  10.  
  11. public class NetworkClient {
  12.    protected Socket serverSocket;
  13.    public PrintStream serverOutput;
  14.    public InputStream serverInput;
  15.  
  16.    public void openServer(String var1, int var2) throws IOException, UnknownHostException {
  17.       if (this.serverSocket != null) {
  18.          this.closeServer();
  19.       }
  20.  
  21.       this.serverSocket = new Socket(var1, var2);
  22.       this.serverOutput = new PrintStream(new BufferedOutputStream(this.serverSocket.getOutputStream()), true);
  23.       this.serverInput = new BufferedInputStream(this.serverSocket.getInputStream());
  24.    }
  25.  
  26.    public void closeServer() throws IOException {
  27.       if (this.serverIsOpen()) {
  28.          if (this.serverSocket != null) {
  29.             this.serverSocket.close();
  30.          }
  31.  
  32.          this.serverSocket = null;
  33.          this.serverInput = null;
  34.          this.serverOutput = null;
  35.       }
  36.    }
  37.  
  38.    public boolean serverIsOpen() {
  39.       return this.serverSocket != null;
  40.    }
  41.  
  42.    public NetworkClient(String var1, int var2) throws IOException {
  43.       this.openServer(var1, var2);
  44.    }
  45.  
  46.    public NetworkClient() {
  47.    }
  48. }
  49.